var t = require("../../../../@babel/runtime/helpers/toConsumableArray"), a = getApp();

Page({
    data: {
        order_id: "",
        truck_list: [],
        value_list: [],
        isLoading: !1,
        isLoadMore: !0,
        page: 1
    },
    onLoad: function(t) {
        t.order_id && this.setData({
            order_id: t.order_id
        });
    },
    onReady: function() {},
    onShow: function() {
        this._initData(), this._getTuck(), this._getOrder_list();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    _initData: function() {
        this.setData({
            truck_list: [],
            value_list: [],
            isLoading: !1,
            isLoadMore: !0,
            page: 1
        });
    },
    _getTuck: function() {
        if (this.data.isLoadMore && !this.data.isLoading) {
            this.setData({
                isLoading: !0
            });
            var i = this, e = a.getNetAddresss("plugin.virtual-card.frontend.order.virtualCardList");
            e += "&order_id=" + this.data.order_id, e += "&page=" + this.data.page, a._getNetWork({
                url: e,
                success: function(a) {
                    var e = a.data;
                    if (1 == e.result) {
                        i.setData({
                            isLoading: !1
                        });
                        var o = e.data.data, s = [];
                        i.setData({
                            truck_list: [].concat(t(i.data.truck_list), t(o))
                        }), i.data.truck_list.forEach(function(t) {
                            s.push(t);
                        }), i.setData({
                            value_list: s
                        });
                    }
                    e.data.total == i.data.page && i.setData({
                        isLoadMore: !1
                    }), i.setData({
                        page: i.data.page + 1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    _getOrder_list: function() {
        var t = this, i = a.getNetAddresss("order.detail");
        i += "&order_id=" + this.data.order_id, a._getNetWork({
            url: i,
            success: function(a) {
                var i = a.data;
                1 == i.result && t.setData({
                    order_list: i.data
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    copybtn: function(t) {
        var a = t.currentTarget.dataset.truckval;
        wx.setClipboardData({
            data: a,
            success: function(t) {
                wx.getClipboardData({
                    success: function(t) {
                        wx.showToast({
                            icon: "none",
                            title: "复制成功",
                            duration: 1500
                        });
                    },
                    fail: function(t) {
                        wx.showToast({
                            icon: "none",
                            title: "复制失败",
                            duration: 1500
                        });
                    }
                });
            }
        });
    }
});